package greate.project.mysql;

import com.mysql.cj.jdbc.MysqlDataSource;
import org.apache.camel.impl.DefaultCamelContext;

public class Main {
    public static void main(String[] args) throws Exception {

        MysqlDataSource dataSource = new MysqlDataSource();
        dataSource.setUrl("jdbc:mysql://120.48.5.4:8806/data-exchange-zs");
        dataSource.setUser("root");
        dataSource.setPassword("baidu@123");



        DefaultCamelContext context = new DefaultCamelContext();
        context.start();

        context.getRegistry().bind("myDataSource", dataSource);

        context.addRoutes(new ProviderRouter("logRouter"));
        context.addRoutes(new LogRouter("logRouter" , "consumerRouter"));
        context.addRoutes(new ConsumerRouter("consumerRouter"));

        context.addRoutes(new LogRouter("logRouter1" , "consumerRouter1"));
        context.addRoutes(new ConsumerRouter("consumerRouter1"));

        Thread.sleep(5000);
        context.addRoutes(new ProviderRouter("logRouter1"));

        synchronized (Main.class){
            Main.class.wait();
        }

    }
}
